﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
using QLNhaSach;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class PhieuNhapDAL
    {
        DataService ds = new DataService();
        public PhieuNhapDAL()
        {
        }
        public String GetLastID()
        {
            String kq = null;
            try
            {
                string sql = "SELECT max(PN_MaPhieuNhap) FROM PHIEUNHAP";
                kq = ds.ExcuteQuery(sql).ToString();
            }
            catch (Exception)
            {
                throw;
            }
            return kq;

        }
        public int InsertPhieuNhap(PhieuNhap pn)
        {
            int kq = 0;
            try
            {
                String sql = "INSERT INTO PHIEUNHAP (PN_NgayNhap) VALUES ('" + pn.NgayNhap + "')";
                kq = ds.ExcuteInsert(sql);
            }
            catch (Exception)
            {
                throw;
            }
            return kq;

        }
        public int DeletePhieuNhap(int maPhieuNhap)
        {
            int kq = 0;
            try
            {
                String sql = "DELETE FROM PHIEUNHAP WHERE PN_MAPHIEUNHAP=" + maPhieuNhap;
                kq = ds.ExcuteInsert(sql);
            }
            catch (Exception)
            {
                throw;
            }
            return kq;

        }
    }
}
